//
// Created by xili on 2024/7/30 8:49.
// Go big or go home.
//
#include <vector>

using namespace std;

//遍历计数
class Solution1 {
public:
    int findMaxConsecutiveOnes(vector<int> &nums) {
        int ans = 0;
        int count = 0;
        for (int i = 0; i < nums.size(); i++) {
            if (nums[i] == 1) {
                count++;
            } else {
                ans = ans > count ? ans : count;
                count = 0;
            }
        }
        return ans;
    }
};

//加上当前数，再乘以当前数
class Solution2 {
public:
    int findMaxConsecutiveOnes(vector<int> &nums) {
        int ans = 0;
        int cur = 0;
        for (auto &item: nums) {
            cur = (cur + item) * item;
            ans = cur > ans ? cur : ans;
        }
        return ans;
    }
};